function [vec] = getangent(func, x, x0)
%GETANGENT - Get the tangent vector of function func at point x
%
    n = length(x);
    % Jacobian matrix without t
    Hx = jacobian(func, x0, 1:n-1);
    sgn = sign(det(Hx));

    % Jacobian matrix with t
    DH = jacobian(func, x);

    % Calcumate C by Formula 4.24
    s = 0;
    for i = 1:n
        s = s + (det([DH(:, 1:i-1), DH(:, i+1:n)]))^2;
    end
    C = (-1)^n * sgn / sqrt(s);

    % Calculate tangent vecotr by Formula 4.23
    vec = zeros(n, 1);
    for i = 1:n-1
        vec(i) = (-1)^i * C * det([DH(:, 1:i-1), DH(:, i+1:n)]);
    end
    vec(n) = (-1)^n * C * det(jacobian(func, x, 1:n-1));
end
